package com.starbaba.externalSMSConfig.service.impl;

import java.util.List;
import java.util.Map;

import com.base.common.database.BaseDao;
import com.base.common.exception.AppException;
import com.base.common.log.LogService;
import com.starbaba.externalSMSConfig.model.SmsConfigResult;
import com.starbaba.externalSMSConfig.service.ExternalSMSService;
import com.starbaba.model.dictionary.Constant;
import com.tuanzi.server.loan_base.model.db.activity.RegisterRecommendActivity;

@SuppressWarnings("deprecation")
public class ExternalSMSServiceImpl implements ExternalSMSService {
	BaseDao dao = new BaseDao(Constant.POOL_LIFE);

	@Override
	public void showpage(Map<String, Object> paramsMap) {
		String sql="select activity_type,activity_type_name from register_recommend_activity";
		
		try {
			List<RegisterRecommendActivity> activityList = dao.list(sql, RegisterRecommendActivity.class);
			paramsMap.put("activityList", activityList);
			
		} catch (AppException e) {
			LogService.error("外部推广短信回拉配置准备数据初始化失败",e);
			e.printStackTrace();
		}
		
	}

	@Override
	public SmsConfigResult saveOrUpdateInfo(String activity_type,int message_type) throws AppException {
		
		RegisterRecommendActivity activityBean = new RegisterRecommendActivity();
		activityBean.setActivity_type(activity_type);
		activityBean.setMessage_type(message_type);
		
		dao.update(activityBean, new String[]{"activity_type"});
		
		SmsConfigResult result = new SmsConfigResult();
		result.setResult("操作成功！");
		
		return result;
	}
}
